//
//  NetDownTalk.h
//  KidReading
//
//  Created by ys on 15/11/5.
//  Copyright © 2015年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "JRAFNetworking.h"
@protocol NetDownloadTalksDelegate <NSObject>
@optional
- (void)netDownloadTalkZipFinished:(NSInteger)originalid;
- (void)netDownloadTalkAllFinished:(NSInteger)originalid;
- (void)netDownloadTalkFileFailed:(NSInteger)originalid;
- (void)netDownloadTalkFilePercentage:(CGFloat)per originalID:(NSInteger)originalid;
@end

@interface TalkDownInfo : NSObject
@property (nonatomic,copy)NSString *urlStr;
@property (nonatomic,assign)NSInteger originalid;
@property (nonatomic,assign)long long edition;
@property (nonatomic,assign)NSInteger talkid;
@end


@interface NetDownTalk : NSObject{
    //存储多个需要下载的任务
    NSMutableArray *downloadTalkArray;
    
    NSMutableArray *delegateArray;
    double totelPercentage;
    double tempTotelPercentage;
}
@property(nonatomic,strong)NSURLSessionDownloadTask *downloadTask;
@property(nonatomic,strong)NSMutableArray *talkUrlArray;

+ (NetDownTalk*)shareSingle;

- (void)downTalkUrl:(NSString*)urlStr withTalkID:(NSInteger)talkid edition:(long long)edition originalID:(NSInteger)originalid;

- (void)checkDownTalkUrl:(NSString*)urlStr withTalkID:(NSInteger)talkid edition:(long long)edition originalID:(NSInteger)originalid complete:(void(^)(BOOL isDone)) complete;

//删除下载任务并移除队列中的任务
-(void)cancelAllDownloadTalkTask;

//根据originalid删除队列中指定的任务
-(void)cancelDownloadTalkTaskWithOriginalID:(NSInteger)originalid;

//注册通知反馈
- (void)registerDownTalkStatusNotice:(id<NetDownloadTalksDelegate>)delegate;
- (void)unRegisterDownTalkStatusNotice:(id<NetDownloadTalksDelegate>)delegate;

@end
